const http = require("http");
let weburl = "http://www.mobiletrain.org/?pinzhuanbdtg=biaoti";
const cheerio = require("cheerio"); // 第三方模块
const fs = require("fs");
http.get(weburl,function(req){
    let str = "";
    req.on("data",chunk=>{
        str += chunk;
    })
    req.on("end",function(){
        // console.log(str);
        let $ = cheerio.load(str);
        let arr = [];
        $(".btn_content a").each((index,item)=>{
            console.log($(item).text());
            let obj = {
                title:$(item).text()
            }
            arr.push(obj); 
        })
        fs.writeFileSync("data.json",JSON.stringify(arr));
        // fs.writeFileSync("1.html",str);
    })
})